import {Dimensions,ToastAndroid,Platform, NativeModules } from 'react-native';
const { StatusBarManager } = NativeModules;

const UI_STANDARD = 375;

class Config {
    static fontSizeDefault = 14;     // 字体
    static colorDefault = '#FFFFFF'; // 颜色
    static sizeMarginDefault = 10;   // 尺寸
    static bottomBarSize = 25;
    static deviceWidth = Dimensions.get('window').width;    // 屏幕宽度
    static deviceHeight = Dimensions.get('window').height;  // 屏幕高度
    static statusBarHeight = Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT;

    // 自适应屏幕（以iOS为模板）
    static scale(width) {
        return Dimensions.get('window').width / UI_STANDARD * width;
    }
}

const Log = (...params) => { // 全局 Log
    if (GLOBAL.__DEV__) {
        console.log(params);
    }
};
const ShowToast = (msg)=>{
    ToastAndroid.showWithGravityAndOffset(
        ""+msg,
        ToastAndroid.SHORT,
        ToastAndroid.BOTTOM,
        0,
        100
    );
};

import Api from './pages/utils/Api'; // 全局 api
import JsonUtil from './pages/utils/JsonUtil';
import BaseComponent from './pages/utils/BaseComponent';
import TimeUtil from './pages/utils/TimeUtil';
import AttributeUtil from './pages/utils/AttributeUtil';
import StorageUtil from './pages/utils/StorageUtil';

// 导出
global.Log = Log;
global.ShowToast = ShowToast;
global.Config = Config;
global.BaseComponent = BaseComponent;
global.AttributeUtil = AttributeUtil;

global.Api = Api;
global.JsonUtil = JsonUtil;
global.TimeUtil = TimeUtil;
global.StorageUtil = StorageUtil;